package designpatterns.singleton;

/**
 * @program: MyTank
 * @description:
 * @author: 王术平
 * @create: 2021-01-05 19:18
 **/
public class SingleTonByIdler {
    //锁直接加载方法上,不需要加volatile
    private static SingleTonByIdler instance = null;

    private SingleTonByIdler() {
    }

    public static synchronized SingleTonByIdler getInstance() {
        if (instance == null) {
            instance = new SingleTonByIdler();
        }
        return instance;
    }
}
